<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@ taglib uri="http://www.springframework.org/security/tags" prefix="sec"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>${viewedAdvertiser.username}'s profile</title>
</head>
<body>
<table>
	<tbody>
	
		<tr>
			<td>Username</td>
			<td>${viewedAdvertiser.username}</td>
		</tr>
		<tr>
			<td>Firstname</td>
			<td>${viewedAdvertiser.firstname}</td>
		</tr>
		<tr>
			<td>Lastname</td>
			<td>${viewedAdvertiser.lastname}</td>
		</tr>
		<tr>
			<td>Type</td>
			<td>${viewedAdvertiser.advertiserType}</td>
		</tr>
		<tr>
			<td>Email</td>
			<td>${viewedAdvertiser.email}</td>
		</tr>
			<tr>
			<td>Address</td>
			<td>${viewedAdvertiser.address}</td>
		</tr>
			<tr>
			<td>Phone number</td>
			<td>${viewedAdvertiser.phoneNumber}</td>
		</tr>
		<tr>
			<td>Registration date</td>
			<td>${viewedAdvertiser.creationTime}</td>
		</tr>
		
		<tr/>
	
		<c:choose>
   			 <c:when test="${empty adverts}">
       			 <tr/>
       			 <tr/>
       			 <tr>
       			 	<td>
       					 No uploaded adverts.
       				</td>
       			 </tr>
  			  </c:when>
   			 <c:otherwise>
   			 	<tr>
					<td>Uploaded adverts</td>
				</tr>
        		<c:forEach items="${adverts}" var="currentAdvert">
					<tr>
						<td>${currentAdvert.title}</td>
						<td>${currentAdvert.abstractText}</td>
						<td>&nbsp;&nbsp;&nbsp;</td>
						<td><a href="${pageContext.request.contextPath}/advertisers/downloadAdvert/${currentAdvert.id}">Download</a></td>
<!-- 						<td>&nbsp;&nbsp;&nbsp;</td> -->
<%-- 						<td><a href="${pageContext.request.contextPath}/adverts/editAdvert/${currentAdvert.id}">Edit</a></td> --%>
						<td>&nbsp;&nbsp;&nbsp;</td>
<%-- 						<td><a href="${pageContext.request.contextPath}/adverts/delete-advert/${currentAdvert.id}">Delete</a></td> --%>
						
						<form:form action="${pageContext.request.contextPath}/admins/delete-advert" method="POST" commandName="deleteAdvertDto">
						<td>
								<form:hidden path="id" value="${currentAdvert.id }" />
								<form:label path="reason">Reason for deletion</form:label>
								<form:input path="reason" required="required" />
								<br>
						</td>
						<td><input type="submit" value="Delete"></td>
						</form:form>
					</tr>
				</c:forEach>
    		</c:otherwise>
		</c:choose>
	</tbody>
</table>
<br><br>
<a href="${pageContext.request.contextPath}/home">Home</a>
</body>
</html>